$(document).ready(function(){
	unicorn.peity();
});

unicorn = {
		// === Peity charts === //
		peity: function(){	

			$.fn.peity.defaults.line = {
			  delimiter: ",",
			  height: 24,
			  max: null,
			  min: 0,
			  stroke: "#FFFFFF",
			  strokeWidth: 1,
			  width: 50
			};

			$.fn.peity.defaults.bar = {
			  delimiter: ",",
			  gap: 1,
			  height: 24,
			  max: null,
			  min: 0,
			  width: 50
			};
		
			$(".peity_line_good span").peity("line", {
				fill: "#459D1C"
			});
			$(".peity_line_bad span").peity("line", {
				fill: "#BA1E20"
			});	
			$(".peity_line_neutral span").peity("line", {
				fill: "#757575"
			});
			$(".peity_bar_good span").peity("bar", {
				fill: ["#459D1C"]
			});
			$(".peity_bar_bad span").peity("bar", {
				fill: ["#BA1E20"]
			});	
			$(".peity_bar_neutral span").peity("bar", {
				fill: ["#757575"]
			});
		},

		// === Tooltip for flot charts === //
		flot_tooltip: function(x, y, contents) {
			
			$('<div id="tooltip">' + contents + '</div>').css( {
				top: y + 5,
				left: x + 5
			}).appendTo("body").fadeIn(200);
		}
};